package com.ruoyi.web.wapper;

import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import com.ruoyi.product.enums.ProdPriceEnum;
import com.ruoyi.product.enums.ProdTypeEnum;
import io.swagger.models.auth.In;

import java.util.List;
import java.util.Map;

public class ProductInfoWapper extends BaseControllerWrapper {

    public ProductInfoWapper(Map<String, Object> single) {
        super(single);
    }

    public ProductInfoWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Integer priceType = (Integer) map.get("priceType");
            if (ObjectUtil.isNotEmpty(priceType)){
                map.put("priceTypeStr", ProdPriceEnum.getNameByValue(priceType));
            }

            Integer type = (Integer) map.get("type");
            if (ObjectUtil.isNotEmpty(type)){
                map.put("typeStr", ProdTypeEnum.getNameByValue(String.valueOf(type)));
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
